<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../datepicker/jquery-ui.min.css">
    <link type="text/css" rel="stylesheet" href="../css/app.css"/>
    <link type="text/css" rel="stylesheet" href="../css/loginMobile.css"/>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="../datepicker/jquery-ui.min.js"></script>
    <script type="text/javascript" src="/pc/js/all.js"></script>
</head>
<body id="Ibody">
<!--
	制作：陈道祥
	页面：主体类型
	更新：九哥
-->




<!-----------身份页面---------->
<div class="stepTwo" id="IstepTwo">
    <div class="identity">服装产业链上下游注册</div>
    <div class="identityDiv">
        <div class="identityItem" id="indentity3" data-id="3">我是工厂</div>
        <div class="identityDesc">纯加工厂，没有自己品牌</div>
    </div>
    <div class="identityDiv">
        <div class="identityItem" id="indentity4" data-id="4">我是工厂</div>
        <div class="identityDesc">有公司有工厂有外发</div>
    </div>
    <div class="identityDiv">
        <div class="identityItem" id="indentity1" data-id="1">我是员工</div>
        <div class="identityDesc">服装产业上下游员工</div>
    </div>
    <div class="identityDiv">
        <div class="identityItem" id="indentity2" data-id="2">我是公司</div>
        <div class="identityDesc">自己没有工厂，全部外发生产</div>
    </div>
    <div class="introMan">
        <input type="text" class="introManPhone"
               placeholder="请输入介绍人手机号码" id="introducer">
    </div>
    <div class="nextStepDiv">
        <!--<span class="prevStep" id="indentityPre">上一步</span>-->
        <!--<span class="nextStep" id="indentityNext">下一步</span>-->
        <div class="nextStepBtn" onclick="setSave()">下一步</div>
    </div>
</div>
<input type="hidden" id="indentity" value="0">
<!-----------身份页面---------->





<!-----------提示信息---------->
<div id="errMsg"></div>
<!-----------提示信息---------->
</body>
<script type="text/javascript" src="../js/login.js"></script>
<script>
    (function(){
        var userInfo = cacheGet('userInfo');
        if (userInfo!='undefined' && userInfo.type!=0) {
            $('#indentity'+userInfo.type).addClass('indentityClick');
            $('#indentity')[0].value = userInfo.type;
        }
    })();
    /**
     * 设置保存
     * */
    function setSave(){
        var type = $('#indentity').val();
        var cate;
        var introducer = $('#introducer').val();
        var userInfo = cacheGet('userInfo'); //获取用户信息
        if (type==0) { getErrMsg('主体身份未设置！',''); return; }
        if (userInfo==null || userInfo.token=='undefined') {
            getErrMsg('没有登录！',''); return;
        }
        //企业类型判断
        if (type==2) { cate = 2; }
        else if (type==3) { cate = 1; }
        else if (type==4) { cate = 3; }
        else { cate = userInfo.cate; } //个人类型
        //存储到本地
        var dataCache = {
            app_access:app_access,
            token:userInfo.token,
            type:type,
            cate:cate
        };
        cacheSet('userInfo',dataCache);
        //同步到线上
        var data = {
            app_access:app_access,
            token:userInfo.token,
            type:type,
            cate:cate,
            introducer:introducer
        };
        $.ajax({
            type:'post',
            url:getDomain() + 'indentity',
            data:data,
            success:function(res){
                //console.log(res); return;
                if (res.code!=0) {
                    getErrMsg(res.msg,''); return;
                }
//                var viewLink = toView(type,0);
//                getErrMsg('设置成功！',viewLink); return;
                window.location.href = toView(type,0);
            },
            error:function(){
                getErrMsg('操作错误！','');
            }
        });
    }
</script>
</html>